﻿<%@ Page Title="" Language="C#" MasterPageFile="~/YouOweMe.Master" AutoEventWireup="true" CodeBehind="Users.aspx.cs" Inherits="YouOweMe.Users" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ObjectDataSource ID="usersDataSource" runat="server" TypeName="YouOweMe.BLL.PeopleManager"
        SelectMethod="GetAllPeople" InsertMethod="InsertOnePeople" UpdateMethod="UpdateOnePeople">
    </asp:ObjectDataSource>
    <asp:ListView ID="UsersListView" runat="server" DataSourceID="usersDataSource" DataKeyNames="ID"
        InsertItemPosition="LastItem">
        <LayoutTemplate>
            <table class="detail_list">
            <thead>
                <tr>
                    <th scope="col">
                        UserName
                    </th>
                    <th scope="col">
                        Initials
                    </th>
                    <th scope="col">
                        Mail
                    </th>
                </tr>
                </thead>
                <tbody>
                <tr id="itemPlaceHolder" runat="server" />
                
        </LayoutTemplate>
        <InsertItemTemplate>
            </tbody>
            </table>
            <div class="form_list">
                <h2>
                    Add an user</h2>
                <dl class="event">
                    <dt>UserName </dt>
                    <dd>
                        <asp:TextBox ID="userNameTextBox" runat="server" Text='<%# Bind("UserName") %>' />
                    </dd>
                    <dt>Initials </dt>
                    <dd>
                        <asp:TextBox ID="InitialsTextBox" runat="server" Text='<%# Bind("Initials") %>' />
                    </dd>
                    <dt>Mail </dt>
                    <dd>
                        <asp:TextBox ID="MailTextBox" runat="server" Text='<%# Bind("Mail") %>' />
                    </dd>
                    <dt>Action </dt>
                    <dd>
                        <asp:Button runat="server" ID="InsertButton" CommandName="Insert" Text="Add an user" />
                        <asp:Button ID="cancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                    </dd>
                </dl>
            </div>
        </InsertItemTemplate>
        <ItemTemplate>
            <tr class='<%# Container.DataItemIndex % 2==0 ? "":"alternating" %>'> 
                <td>
                    <%# Eval("UserName") %>
                </td>
                <td>
                    <%# Eval("Initials") %>
                </td>
                <td>
                    <%# Eval("Mail") %>
                </td>
                <td>
                    <asp:Button ID="editButton" runat="server" CommandName="Edit" Text="Edit"/>
                </td>
            </tr>
        </ItemTemplate>
        <EditItemTemplate>
            <tr>
                <td>
                    <%# Eval("UserName") %>
                </td>
                <td>
                    <asp:TextBox ID="EditInitialsTextBox" runat="server" Text='<%# Bind("Initials") %>' />
                </td>
                <td>
                    <asp:TextBox ID="EditMailTextBox" runat="server" Text='<%# Bind("Mail") %>' />
                </td>
                <td>
                    <asp:Button ID="selectButton" runat="server" CommandName="Update" Text="Update"/>
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" CausesValidation="false" Text="Cancel"/>
                </td>
            </tr>
        </EditItemTemplate>
    </asp:ListView>

</asp:Content>
